package ch14;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class Notepad extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    String input = "";

    @Override
    public void start(Stage primaryStage) throws Exception {
        Pane mainpane = new Pane();
        Label output = new Label("请输入");
        mainpane.getChildren().add(output);
        Scene scene = new Scene(mainpane, 200, 50);
        primaryStage.setScene(scene);
        primaryStage.show();
        mainpane.setOnKeyPressed(e -> {
            if (e.getCode() == KeyCode.ENTER) {
                output.setText(input);
                input = "";
            } else
                input += e.getText();
        });
        mainpane.requestFocus();
    }
}